package com.t209.hibernatelearn.dao;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;

public class HibernateUtil {
    private static Configuration configuration;
    private static final SessionFactory SESSIONFACTORY;

    static {
        try {
            configuration=new Configuration();
            Configuration configuration1=configuration.configure();
            SESSIONFACTORY=configuration1.buildSessionFactory();
        }catch(HibernateException e) {
            throw new ExceptionInInitializerError(e);
        }
    }
    private HibernateUtil(){}
    public static Session currentSession(){return SESSIONFACTORY.getCurrentSession();}
}
